<?php

namespace App\Entity;

use App\Repository\NoticeTypeRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=NoticeTypeRepository::class)
 * @ORM\Table(options={"comment":"消息类型表"})
 * @ORM\HasLifecycleCallbacks()
 */
class NoticeType {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $title;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $description;

    /**
     * @ORM\Column(type="integer", nullable=true, options={"default"="0","comment"="类型 0站内信 1短信"})
     */
    private $type;

    /**
     * @ORM\Column(type="boolean", nullable=true, options={"default"="1","comment"="状态 0禁用 1启用"})
     */
    private $status;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $updated_at;

    public function getId (): ?int {
        return $this->id;
    }

    public function getTitle (): ?string {
        return $this->title;
    }

    public function setTitle (string $title): self {
        $this->title = $title;

        return $this;
    }

    public function getDescription (): ?string {
        return $this->description;
    }

    public function setDescription (?string $description): self {
        $this->description = $description;

        return $this;
    }

    public function getStatus (): ?bool {
        return $this->status;
    }

    public function setStatus (?bool $status): self {
        $this->status = $status;

        return $this;
    }

    public function getCreatedAt (): ?\DateTimeInterface {
        return $this->created_at;
    }

    public function setCreatedAt (?\DateTimeInterface $created_at): self {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt (): ?\DateTimeInterface {
        return $this->updated_at;
    }

    public function setUpdatedAt (?\DateTimeInterface $updated_at): self {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * 新建之前
     * @ORM\PrePersist()
     */
    public function prePersistHook () {
        // 添加创建时间
        $this->created_at = new \DateTime();
    }

    /**
     * 更新之前
     * @ORM\PostPersist()
     */
    public function postPersistHook () {
        // 添加更新时间
        $this->updated_at = new \DateTime();
    }

    public function getType(): ?int
    {
        return $this->type;
    }

    public function setType(?int $type): self
    {
        $this->type = $type;

        return $this;
    }
}
